package com.cancer.biz.datasource;

/**
 * 数据源管理器。
 * 设置当前线程所访问的数据源。
 * 
 * @company GeekPlus
 * @project beetle
 * @author 刘俊
 * @date Jun 15, 2017
 * @since 1.0.0
 */
public class DataSourceTypeManager {
	private static final ThreadLocal<DataSourceType> dataSourceTypes = new ThreadLocal<DataSourceType>() {
		protected DataSourceType initialValue() {
			return DataSourceType.MASTER; // 默认访问MASTER
		}
	};

	public static DataSourceType get() {
		return dataSourceTypes.get();
	}

	public static void set(DataSourceType dataSourceType) {
		dataSourceTypes.set(dataSourceType);
	}

	public static void reset() {
		dataSourceTypes.set(DataSourceType.MASTER);
	}
}
